<?php
namespace core\lib;
/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class route{
    public $ctl;
    public $act;
    public function __construct() {
        //p($_SERVER);
        //  处理url地址 /index/index
        $url = $_SERVER['REQUEST_URI'];
        if(isset($_SERVER['REQUEST_URI']) && $url != '/'){
            $path = explode('/',trim($url,'/'));
            if(isset($path[0])){
                $this->ctl = $path[0];
            }
            unset($path[0]);
            if(isset($path[1])){
                $this->act = $path[1];
                unset($path[1]);
            }else{
                $this->act = 'index';
            }
            
        }else{
            $this->ctl = 'index';
            $this->act = 'index';
        }
        
        //处理get参数
        $count = count($path)+2;
        $i = 2;
        while ($i < $count){
            if(isset($path[$i+1])){
                $_GET[$path[$i]] = $path[$i+1];
            }
            $i += 2;
        }
        //p($_GET);
        
    }
    
    
}
